Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Interactive without setting verbosity explicitly in dotnet tool restore Fixes #22987 #45312

Merged
merged 3 commits into from
Dec 20, 2024

Conversation

Forgind
Copy link
Member

@Forgind Forgind commented Dec 4, 2024

Fixes #22987

We don't currently pass a RestoreActionConfig from ToolRestoreCommand to the ToolPackageDownloader (and by extension the NuGetPackageDownloader) we actually use to install the tool. This corrects that error.

Additionally, the default verbosity is quiet. When the interactive flag is passed, that effectively suppresses it. This increases the default verbosity from quiet to minimal when interactive is requested.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Tools untriaged Request triage from a team member labels Dec 4, 2024
@Forgind Forgind marked this pull request as draft December 4, 2024 17:25
@Forgind
Copy link
Member Author

Forgind commented Dec 20, 2024

I had a lot of difficulty testing this. Special thanks to @nkolev92 for suggesting an authenticated feed I could use for testing, which ended up working beautifully once I figured out a way to get rid of my tokens.

Screenshots in action:
Without --interactive:
image

With --interactive (but not verbosity):
image

@Forgind Forgind marked this pull request as ready for review December 20, 2024 15:38
Comment on lines +66 to +74
if (!result.HasOption(ToolRestoreCommandParser.VerbosityOption) && result.GetValue(ToolCommandRestorePassThroughOptions.InteractiveRestoreOption))
{
_verbosity = VerbosityOptions.minimal;
}

_restoreActionConfig = new RestoreActionConfig(DisableParallel: result.GetValue(ToolCommandRestorePassThroughOptions.DisableParallelOption),
NoCache: result.GetValue(ToolCommandRestorePassThroughOptions.NoCacheOption) || result.GetValue(ToolCommandRestorePassThroughOptions.NoHttpCacheOption),
IgnoreFailedSources: result.GetValue(ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption),
Interactive: result.GetValue(ToolCommandRestorePassThroughOptions.InteractiveRestoreOption));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! I have two broad comments:

  • I feel like I've seen this 'verbosity needs to be downstream of some other configuration' problem in a few different places in the codebase - is it something that you think we could detect and extract to prevent playing whack-a-mole?
  • the set of parameters to the RestoreActionConfig seem very 'regular' (in the sense of common/not-changing) - is there a way we could enforce that
    • commands that use RestoreActionConfig have the required options applied to them and
    • something in the way those commands are processed/executed automatically configures a RestoreActionConfig? Again focusing on 'How can we be consistent by design' here instead of playing whack-a-mole. Maybe a middleware or extension method on ParseResult or something?

@Forgind Forgind merged commit fcba596 into dotnet:main Dec 20, 2024
35 of 37 checks passed
@Forgind Forgind deleted the default-verbosity-supports-interactive branch December 20, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Tools untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dotnet tool restore interactive doesn't prompt for DeviceFlow since .NET 6 SDK
2 participants